package errors

// common Error type
const (
	None Type = 0

	Unauthorized                Type = 1000
	InvalidToken                Type = iota + 1000 // 无效的令牌。
	TokenExpired                                   // 令牌过期。
	UploadError                                    //上传失败
	EmptyParameter                                 //参数为空
	ParameterLengthExceedsLimit                    //参数长度超过限制
	EmptyVerificationCode                          //验证码为空
	VerificationCodeError                          //验证码错误
	CaptchaError                                   //验证码获取错误
	NoData                                         //未找到有效数据
	ParameterErr                                   //参数错误
	NotPermission                                  // 没有权限
	ErrParamsParse              Type = iota + 1000
)

const (
	BadRequest Type = iota + 2000
	Forbidden
	NotFound
	InternalServerError
	NotImplemented
	ServiceUnavailable
)

const (
	FeePlanNotExist Type = iota + 3000 //不存在的套餐计划
)

func (t Type) String() string {
	switch t {
	case None:
		return "none"
	case BadRequest:
		return "bad request"
	case Unauthorized:
		return "unauthorized"
	case Forbidden:
		return "forbidden"
	case NotFound:
		return "not found"
	case InternalServerError:
		return "internal server errors"
	case NotImplemented:
		return "not implemented"
	case ServiceUnavailable:
		return "service unavailable"
	case FeePlanNotExist:
		return "不存在的套餐计划"
	default:
		return ""
	}
}
